import request from '@/utils/request'
import MapUtils from '@/utils/mapUtils'
// 查询座位列表
export function listSeat(query) {
  return request({
    url: '/system/seat/list',
    method: 'get',
    params: query
  }).then(response => {
    // 成功获取数据后设置座位映射
    if (response.code === 200 && response.rows) {
      MapUtils.setSeatMap(response.rows);
    }
    return response;
  });
}

// 查询座位详细
export function getSeat(id) {
  return request({
    url: '/system/seat/' + id,
    method: 'get'
  })
}

// 新增座位
export function addSeat(data) {
  return request({
    url: '/system/seat',
    method: 'post',
    data: data
  })
}

// 修改座位
export function updateSeat(data) {
  return request({
    url: '/system/seat',
    method: 'put',
    data: data
  })
}
// 修改座位状态
export function updateSeatStatus(id) {
  return request({
    url: `/system/seat/status?id=${id}`,
    method: 'put',
    
  })
}

// 删除座位
export function delSeat(id) {
  return request({
    url: '/system/seat/' + id,
    method: 'delete'
  })
}
